import {createSlice} from '@reduxjs/toolkit';

const dispatchingSlice = createSlice({
  name: 'dispatching',
  initialState: {
    dispatching : [],
  },
  reducers: {
    // 设置待配送列表
    setDispatchingList: (state, action) => {
      const {payload} = action;
      state.dispatching = payload;
    },
    // 清空待配送列表
    clearDispatchingList: (state, action) => {
      const {payload} = action;
      state.dispatching = payload;
    },
  },
});
//从 dispatchingSlice.actions 中解构出 increment 和 decrement action creators，以便在应用程序中使用它们来分发相应的 action
export const {setDispatchingList, clearDispatchingList} = dispatchingSlice.actions;
//返回 reducer供combineReducers组装
export default dispatchingSlice.reducer;
